package com.isoft.c2team3service2.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.isoft.c2team3service2.entity.UserFollowUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserFollowUserMapper extends BaseMapper<UserFollowUser> {

    /**
     * 检查用户关注状态
     */
    @Select("SELECT COUNT(*) FROM user_follow_user WHERE user_id = #{userId} AND followed_user_id = #{followedUserId}")
    int checkFollowStatus(@Param("userId") Integer userId, @Param("followedUserId") Integer followedUserId);

    /**
     * 获取用户关注的用户ID列表
     */
    @Select("SELECT followed_user_id FROM user_follow_user WHERE user_id = #{userId}")
    List<Integer> selectFollowedUserIds(@Param("userId") Integer userId);

    /**
     * 获取关注用户的粉丝ID列表
     */
    @Select("SELECT user_id FROM user_follow_user WHERE followed_user_id = #{userId}")
    List<Integer> selectFanUserIds(@Param("userId") Integer userId);
}
